home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / sounddt41src / boopsistubs.h < prev    next >
C/C++ Source or Header  |  1999-04-19  |  3KB  |  118 lines

  1. #ifndef BOOPSISTUBS_H
  2. #define BOOPSISTUBS_H
  3. /*
  4. **    $VER: BoopsiStubs.h 1.2 (1.9.97)
  5. **
  6. **    Copyright (C) 1997 Bernardo Innocenti. All rights reserved.
  7. **
  8. **    Use 4 chars wide TABs to read this file
  9. **
  10. **    Using these inline versions of the amiga.lib boopsi support functions
  11. **    results in faster and smaller code against their linked library
  12. **    counterparts. When debug is active, this function also validate the
  13. **    parameters you pass in.
  14. **
  15. */
  16.  
  17. #ifndef COMPILERSPECIFIC_H
  18. #include "CompilerSpecific.h"
  19. #endif /* COMPILERSPECIFIC_H */
  20.  
  21. #ifndef DEBUG_H
  22. #include "Debug.h"
  23. #endif /* DEBUG_H */
  24.  
  25.  
  26. /* the _HookPtr type is a shortcut for a pointer to a hook function */
  27.  
  28. typedef ASMCALL ULONG (*_HookPtr)
  29.     (REG(a0, Class *), REG(a2, Object *), REG(a1, APTR));
  30.  
  31. INLINE ULONG CoerceMethodA (struct IClass *cl, Object *o, Msg message)
  32. {
  33.     ASSERT_VALIDNO0(cl)
  34.     ASSERT_VALID(o)
  35.  
  36.     return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)message);
  37. }
  38.  
  39. INLINE ULONG DoSuperMethodA (struct IClass *cl, Object *o, Msg message)
  40. {
  41.     ASSERT_VALIDNO0(cl)
  42.     ASSERT_VALID(o)
  43.  
  44.     cl = cl->cl_Super;
  45.     return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)message);
  46. }
  47.  
  48. INLINE ULONG DoMethodA (Object *o, Msg message)
  49. {
  50.     Class *cl;
  51.     ASSERT_VALIDNO0(o)
  52.     cl = OCLASS (o);
  53.     ASSERT_VALIDNO0(cl)
  54.  
  55.     return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)message);
  56. }
  57.  
  58.  
  59.     #define CoerceMethod(cl, o, msg...)                                                \
  60.     ({                                                                                \
  61.         ULONG _msg[] = { msg };                                                        \
  62.         ASSERT_VALIDNO0(cl)                                                            \
  63.         ASSERT_VALID(o)                                                                \
  64.         ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)_msg);        \
  65.     })
  66.  
  67.     #define DoSuperMethod(cl, o, msg...)                                            \
  68.     ({                                                                                \
  69.         Class *_cl;                                                                    \
  70.         ULONG _msg[] = { msg };                                                        \
  71.         ASSERT_VALID(o)                                                                \
  72.         ASSERT_VALIDNO0(cl)                                                            \
  73.         _cl = cl = cl->cl_Super;                                                    \
  74.         ASSERT_VALIDNO0(_cl)                                                        \
  75.         ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg);    \
  76.     })
  77.  
  78.     #define DoMethod(o, msg...)                                                        \
  79.     ({                                                                                \
  80.         Class *_cl;                                                                    \
  81.         ULONG _msg[] = { msg };                                                        \
  82.         ASSERT_VALIDNO0(o)                                                            \
  83.         _cl = OCLASS(o);                                                            \
  84.         ASSERT_VALIDNO0(_cl)                                                        \
  85.         ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg);    \
  86.     })
  87.  
  88.     /* Var-args stub for the OM_NOTIFY method */
  89.     #define NotifyAttrs(o, gi, flags, attrs...)                                        \
  90.     ({                                                                                \
  91.         Class *_cl;                                                                    \
  92.         ULONG _attrs[] = { attrs };                                                    \
  93.         ULONG _msg[] = { OM_NOTIFY, (ULONG)_attrs, (ULONG)gi, flags };                \
  94.         ASSERT_VALIDNO0(o)                                                            \
  95.         _cl = OCLASS(o);                                                            \
  96.         ASSERT_VALIDNO0(_cl)                                                        \
  97.         ASSERT_VALID(gi)                                                            \
  98.         ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg);    \
  99.     })
  100.  
  101.     /* Var-args stub for the OM_UPDATE method */
  102.     #define UpdateAttrs(o, gi, flags, attrs...)                                        \
  103.     ({                                                                                \
  104.         Class *_cl;                                                                    \
  105.         ULONG _attrs[] = { attrs };                                                    \
  106.         ULONG _msg[] = { OM_UPDATE, (ULONG)_attrs, (ULONG)gi, flags };                \
  107.         ASSERT_VALIDNO0(o)                                                            \
  108.         _cl = OCLASS(o);                                                            \
  109.         ASSERT_VALIDNO0(_cl)                                                        \
  110.         ASSERT_VALID(gi)                                                            \
  111.         ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg);    \
  112.     })
  113.  
  114. /* Nobody else needs this anymore... */
  115. #undef _HookPtr
  116.  
  117. #endif /* !BOOPSISTUBS_H */
  118.